<template>
  <section>
    <!--工具条-->
    <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
      <el-form :inline="true" :model="filters">
        <el-form-item>
          <el-input v-model="filters.keyword" placeholder="关键字"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" v-on:click="query">查询</el-button>
        </el-form-item>
      </el-form>
    </el-col>

    <!--列表  v-loading="listLoading"-->
    <el-table :data="journals" highlight-current-row   @selection-change="selsChange" style="width: 100%;">
      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column type="index" label="编号" width="60">
      </el-table-column>
      <el-table-column prop="journalId" label="日志编号" width="80" >
      </el-table-column>
      <el-table-column prop="username" label="用户名" width="80" >
      </el-table-column>
      <el-table-column prop="operation" label="日志详情" width="150" >
      </el-table-column>
      <el-table-column prop="method" label="请求方法" width="260" >
      </el-table-column>
      <el-table-column prop="params" label="请求参数" width="200" >
      </el-table-column>
      <el-table-column prop="time" label="操作时长" width="80" >
      </el-table-column>
      <el-table-column prop="ip" label="ip地址" width="100" >
      </el-table-column>
      <el-table-column prop="createDate" label="创建时间" width="200" >
      </el-table-column>
    </el-table>
    <!--工具条-->
    <el-col :span="24" class="toolbar">
      <el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button>
      <el-pagination layout="prev, pager, next" @current-change="handleCurrentChange"
                     :page-size="pageSize"
                     :total="totals"
                     :current-page="currentPage"
                     style="float:right;">
      </el-pagination>
    </el-col>

  </section>
</template>

<script>
import util from '../../common/js/util'
//import NProgress from 'nprogress'

export default {
  data() {
    return {
      // 是否置灰
      submissionFlag:false,
      logName:"",
      // 高级查询
      filters: {
        keyword: ''
      },
      // 列表数据
      journals: [],
      // 总条数
      totals: 0,
      // 当前页条数
      pageSize: 5,
      // 当前页
      currentPage:1,
      // 页面忙等
      listLoading: false,
      sels: [],//列表选中列
    }
  },
  methods: {
    query() {
      // 高级查询定位第一页
      this.currentPage = 1;
      this.getJournals();
    },
    //性别显示转换
    formatSex: function (row, column) {

    },
    // 点击页数
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getJournals();
    },

    //获取部门列表
    getJournals() {
      // 携带到后端的参数
      let para = {
        pageSize: this.pageSize,
        currentPage: this.currentPage,
        keyword: this.filters.keyword
      };
      console.log(para)
      // 忙等
      this.listLoading = true;
      //NProgress.start();
      // 发送axios请求获取后端数据
      this.$http.post("/log",para)
        .then(result=>{
          // 关闭忙等
          this.listLoading = false;
          console.log(result);
          // 列表数据赋值
          this.journals = result.data.rows;
          // totals赋值
          this.totals = result.data.totals;
          // console.log(result.data.totals);
        })
        .catch(result=>{
          // 请求失败
          this.$message({
            message: '网络繁忙',
            type: 'error'
          });
        })
    },
    selsChange: function (sels) {
      this.sels = sels;
    },
  },
  mounted() {
    this.getJournals();
  }
}
</script>

<style scoped>

</style>
